import sys
from PyQt5.QtSql import QSqlDatabase, QSqlQueryModel, QSqlQuery
from PyQt5.QtWidgets import QApplication, QMainWindow, QTableView
from mydb import MyDb
def createConnection():
    db = QSqlDatabase.addDatabase("QSQLITE")
    # 在这里设置你的数据库信息
    db.setDatabaseName("example.db")
    if not db.open():
        print("Cannot establish a database connection.")
        return False
    return True

if __name__ == '__main__':
    app = QApplication(sys.argv)
    db=MyDb()
    # if not createConnection():
    #     sys.exit(1)

    query = QSqlQueryModel()
    query.setQuery("SELECT * FROM std_result")
    print(dir(query))
    # query.setEditStrategy(QSqlQueryModel.OnFieldChange)

    view = QTableView()
    view.setModel(query)
    view.show()

    sys.exit(app.exec_())
